package com.sg.hms.ServiceImpl;

import net.sf.json.JSONObject;

import com.sg.hms.Dao.FoodMenuDao;
import com.sg.hms.DaoImpl.FoodMenuDaoImpl;
import com.sg.hms.Service.FoodMenuService;

public class FoodMenuServiceImpl implements FoodMenuService{
	FoodMenuDao fmdao=new FoodMenuDaoImpl();
	@Override
	public JSONObject getFoods(int start, int pageSize, int uid) {
		JSONObject foods=new JSONObject();
		foods.put("total",fmdao.getFoodMenusCounts(uid));
		foods.put("rows", fmdao.getFoods(start, pageSize, uid));
		return foods;
	}

	@Override
	public JSONObject getFoods(int start, int pageSize, int uid,
			String searchname) {
		JSONObject foods=new JSONObject();
		foods.put("total",fmdao.getFoodMenusCounts(uid));
		foods.put("rows", fmdao.geFoods(start, pageSize, uid, searchname));
		return foods;
	}

	@Override
	public int addFoodMenus(int elID,String fmName,double price,String content) {		
		return fmdao.addFoodMenu(elID, fmName, price, content);
	}

	@Override
	public int deleteFoodMenus(int fmId) {
		return fmdao.deleteFoodMenus(fmId);
	}

	@Override
	public int updateFoodMenus(int fmid, String fmName, int price,
			String content) {
		return fmdao.updateFoodMenus(fmid, fmName, price, content);
	}

	@Override
	public JSONObject getFoods(int start,int pageSize) {
		JSONObject foods=new JSONObject();
		foods.put("total",fmdao.getFoodMenusCounts());
		foods.put("rows", fmdao.getFoods(start, pageSize));
		//System.out.println(foods);
		return foods;
	}

}
